package com.example.springtransaction.service;

import com.example.springtransaction.mapper.LogInfoMapper;
import com.example.springtransaction.mapper.UserMapper;
import com.example.springtransaction.model.LogInfo;
import com.example.springtransaction.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    @Autowired
    private LogInfoMapper logInfoMapper;

    @Transactional
    public int addUser(UserInfo userInfo){
        int ret = userMapper.addUser(userInfo);
        System.out.println("添加用户：" + ret);
        // 我们不管 用户信息是否添加成功，都使用日志记录下来。
//        LogInfo logInfo = new LogInfo();
//        logInfo.setName("添加用户");
//        logInfo.setDesc("添加用户的结果：" + ret);
//        logInfoMapper.addLog(logInfo);
        return  ret;
    }
}
